home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20031118-20041115 / 000399_slash_dev_slas…_2000@yahoo.com_Wed Sep 22 09:14:02 2004.msg < prev    next >
Internet Message Format  |  2020-01-01  |  5KB

  1. Path: newsmaster.cc.columbia.edu!panix!newsfeed.media.kyoto-u.ac.jp!postnews1.google.com!k26g2000oda.googlegroups.com!not-for-mail
  2. From: "Mark Sapiro" <slash_dev_slash_null_2000@yahoo.com>
  3. Newsgroups: comp.protocols.kermit.misc
  4. Subject: Re: Return codes and If statments
  5. Date: 21 Sep 2004 21:30:19 -0700
  6. Organization: http://groups.google.com
  7. Lines: 166
  8. Message-ID: <1095827419.338981.28270@k26g2000oda.googlegroups.com>
  9. References: <3f9c05b0.0409211252.5aa51cb1@posting.google.com>
  10.    <slrncl18i5.56s.fdc@sesame.cc.columbia.edu>
  11. NNTP-Posting-Host: 209.182.169.133
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset="iso-8859-1"
  14. X-Trace: posting.google.com 1095827419 19272 127.0.0.1 (22 Sep 2004 04:30:19 GMT)
  15. X-Complaints-To: groups-abuse@google.com
  16. NNTP-Posting-Date: Wed, 22 Sep 2004 04:30:19 +0000 (UTC)
  17. In-Reply-To: <slrncl18i5.56s.fdc@sesame.cc.columbia.edu>
  18. User-Agent: G2/0.2
  19. Complaints-To: groups-abuse@google.com
  20. Injection-Info: k26g2000oda.googlegroups.com; posting-host=209.182.169.133;
  21.    posting-account=iQNWIg0AAAAD2fStXNC9nwGlPdSqjWrI
  22. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15177
  23.  
  24. Frank da Cruz wrote:
  25. > On 2004-09-21, Peter V. <dm_v_2000@yahoo.com> wrote:
  26. > : I am modifying a C-Kermit script I have to not continue processing
  27. > : if a call to another script does not return a value of 1 (We are
  28. doing
  29. > : this for fail over testing).
  30. > :
  31. > : Here is the C-Kermit code in question:
  32. > :
  33. > : # run the db_status script in the CRON directory
  34. > : run db_status
  35. > :
  36. > : # See if the ret value is != 1
  37. > : #  If it != 1 tell user we are not on the primay server and then
  38. > : exit).
  39. > :
  40. > : if != \v(pexitstat) 1
  41. > :  {
  42. > :    echo Return code != 1 ... Not the primary server
  43. > :    echo return code =  \v(pexitstat)
  44. > :    exit
  45. > :
  46. > :   }
  47. > : # otherwise we are on the primary server so continue processing
  48. > : ...
  49. > : ...
  50. > : ...
  51. > :
  52. > : When I run this on the Secondary server it works (since the result
  53. > : returned from the db_status script is a 2 since it is not the
  54. primary
  55. > : server).
  56. > :
  57. > : However, when I test this on the primay server the code exits
  58. (meaning
  59. > : it executes the body of the if statment above) despite the fact
  60. that
  61. > : the return code from db_status is 1.
  62. > :
  63. > : Any suggestions, as to what I'm doing wrong?
  64. > :
  65. > My first suggestion is to use the recommended format for grouping
  66. statements:
  67. >
  68. >   if != \v(pexitstat) 1 {
  69. >       echo Return code != 1 ... Not the primary server
  70. >       echo return code =  \v(pexitstat)
  71. >       exit
  72. >   }
  73. >
  74. > If that doesn't help, then check to see what the subprocess actually
  75. > returns as its exit code (OK, you say it is 1 but...).  If so, then
  76. make sure
  77. > you are running the current version of C-Kermit, which is 8.0.211.
  78. If you
  79. > are, then we're in for some debugging; contact
  80. kermit-support@columbia.edu.
  81. >
  82. > - Frank
  83.  
  84.  
  85. Frank's suggestion will help. This is another case of if { } else { }
  86. constructs that only work if written in certain ways.
  87.  
  88. I've mentioned this before, but the document
  89.  
  90. http://www.columbia.edu/kermit/ckermit70.html
  91.  
  92. contains several examples of if/else coding in section 7.20.1. The
  93. first four of these are
  94.  
  95. Example 1:
  96.  
  97. IF condition { command1, command2 } ELSE { command3, command4 }
  98.  
  99. Example 2 (same as Example 1):
  100.  
  101. IF condition {
  102. command1
  103. command2
  104. } ELSE {
  105. command3
  106. command4
  107. }
  108.  
  109. Example 3 (same as 1 and 2):
  110.  
  111. IF condition {
  112. command1
  113. command2
  114. }
  115. ELSE { command3, command4 }
  116.  
  117. Example 4 (same as 1-3):
  118.  
  119. IF condition {
  120. command1
  121. command2
  122. }
  123. ELSE {
  124. command3
  125. command4
  126. }
  127.  
  128. In examples 3 and 4, various problems occur in execution of the ELSE
  129. clause when the condition is false. This change happened somewhere
  130. between 8.0.201 and 8.0.206 due to changes in the handling of
  131. "immediate macros". This is illustrated by the following.
  132.  
  133. fog: {14} $ cat kt3
  134. # Example 1:
  135.  
  136. IF false { .theday := \v(day), show macro theday } ELSE { .thedate :=
  137. \v(date), show macro thedate }
  138.  
  139. # Example 2 (same as Example 1):
  140.  
  141. IF false {
  142. .theday := \v(day)
  143. show macro theday
  144. } ELSE {
  145. .thedate := \v(date)
  146. show macro thedate
  147. }
  148.  
  149. # Example 3 (same as 1 and 2):
  150.  
  151. IF false {
  152. .theday := \v(day)
  153. show macro theday
  154. }
  155. ELSE { .thedate := \v(date), show macro thedate }
  156.  
  157. # Example 4 (same as 1-3):
  158.  
  159. IF false {
  160. .theday := \v(day)
  161. show macro theday
  162. }
  163. ELSE {
  164. .thedate := \v(date)
  165. show macro thedate
  166. }
  167. fog: {15} $ kermit
  168. Executing /home_mo/msapiro/.kermrc for UNIX...
  169. Executing /home_mo/msapiro/.mykermrc...
  170. Good Evening.
  171. C-Kermit 8.0.212 Dev.00, 10 May 2004, for HP-UX 11.00
  172. Copyright (C) 1985, 2004,
  173. Trustees of Columbia University in the City of New York.
  174. Type ? or HELP for help.
  175. (/home_mo/msapiro/) C-Kermit>take kt3
  176. thedate = 21 Sep 2004
  177. thedate = 21 Sep 2004
  178. thedate = \v(date)
  179. thedate = \v(date)
  180. (/home_mo/msapiro/) C-Kermit>
  181.  
  182. I have trained myself to always code if/else in the "recommended
  183. format", but it would be nice if the examples that no longer work were
  184. removed from the documentation.
  185.  
  186. --
  187. Mark Sapiro msapiro at value dot net       The highway is for gamblers,
  188. San Francisco Bay Area, California    better use your sense - B. Dylan
  189.